#include "IMethods.h"
#include "Jacobi.h"
#include "Gauss.h"
#include "CGM.h"
#include "NCGM.h"
#include "LOS.h"
#include "GSM.h"

using namespace APIMethods;

shared_ptr<IMethods> IMethods::createInstance(EMethods Method_, shared_ptr<const Matrix> SLAEMatrix, shared_ptr<const Matrix> Preconditioner,
	shared_ptr<const Vector> RightPart, shared_ptr<const Vector> Approximation = nullptr)
{	
	shared_ptr<IMethods> result = nullptr;

	switch (Method_)
	{
	//case EMethods::Gauss:
	//	result = shared_ptr<IMethods>(new Method::Gauss(SLAEMatrix, Preconditioner, RightPart, Approximation));
	//	break;
	case EMethods::Jacobi:
		result = shared_ptr<IMethods>(new Method::Jacobi(SLAEMatrix, Preconditioner, RightPart, Approximation));
		break;
	case EMethods::CGM:
		result = shared_ptr<IMethods>(new Method::CGM(SLAEMatrix, Preconditioner, RightPart, Approximation));
		break;
	case EMethods::NCGM:
		result = shared_ptr<IMethods>(new Method::NCGM(SLAEMatrix, Preconditioner, RightPart, Approximation));
		break;
	case EMethods::LOS:
		result = shared_ptr<IMethods>(new Method::LOS(SLAEMatrix, Preconditioner, RightPart, Approximation));
		break;
	case EMethods::GSM:
		result = shared_ptr<IMethods>(new Method::GSM(SLAEMatrix, Preconditioner, RightPart, Approximation));
		break;
	default:
		break;
	}

	return result;
}

shared_ptr<Vector> IMethods::getResult() const
{
	return _result;
}

double IMethods::getResidual() const
{
	return _residual;
}
